/**
 * 
 */
package de.cbf.cam.dsa.battle.logic.commands;

import java.util.ArrayList;
import java.util.List;

import de.cbf.cam.dsa.battle.exceptions.ParseCommandException;
import de.cbf.cam.dsa.model.entities.OneNPC;
import de.cbf.cam.dsa.model.entities.states.stateChanger.StateChangerATPA;
import de.cbf.cam.dsa.model.entities.states.stateChanger.StateChangerBase;

/**
 * @author Nebelritter
 *
 */
public class OneCommandChangePA extends OneCommandBase {

	/**
	 * 
	 */
	public OneCommandChangePA() {
		super();
		name = "pa:";
	}

	@Override
	public List<StateChangerBase> evaluateCommand(String oneCommand)
			throws ParseCommandException {
		List<StateChangerBase> stateChangersResult = new ArrayList<StateChangerBase>();		
		try{
			String stringValues=oneCommand.substring(name.length(),oneCommand.length()-1);
			Integer value = Integer.parseInt(stringValues);
			String handValue = oneCommand.substring(oneCommand.length()-1,oneCommand.length());
			String hand;
			if(handValue.equals("s")){
				hand = OneNPC.Hand_Second;
			}else{
				hand = OneNPC.Hand_Main;
			}			
			StateChangerATPA changePA = new StateChangerATPA(0,value,hand);
			stateChangersResult.add(changePA);
			
		}catch (NumberFormatException e) {
			throw new ParseCommandException("Wrong parameters :",e);
		}catch (StringIndexOutOfBoundsException e){
			throw new ParseCommandException("Wrong parameters :",e);
		}		
		return stateChangersResult;
	}

}
